﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using MindASPCoreWebAPI.ApiLibrary.PermissionsValidation;
using MindASPCoreWebAPI.DtoModel.Common;
using MindASPCoreWebAPI.PoModel.SystemManager;
using MindASPCoreWebAPI.Service.SystemManager;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace MindASPCoreWebAPI.ApiProject.Area.SystemManager
{ 
    //公司 控制器
    [ApiModuleRelation("companyadmin_manager")]
    public class CompanyAdminController : SystemManagerBaseController
    {
        //BLL依赖注入
        private CompanyAdminService  _companyAdminService;
        public CompanyAdminController(CompanyAdminService companyAdminService)
        {
            _companyAdminService = companyAdminService;
        }


        //行业下拉
        [HttpGet]
        public ResultModel<List<IndustryAdminModel>> Down_IndustryAdminModel()
        {
            try
            {
                var data = _companyAdminService.Down_IndustryAdminModel();
                return MyOk(data);
            }

            catch (Exception)
            {

                throw;
            }
        }

        //公司性质下拉
        [HttpGet]
        public ResultModel<List<NatModel>> Down_NatModel()
        {
            try
            {
                var data = _companyAdminService.Down_NatModel();
                return MyOk(data);
            }

            catch (Exception)
            {

                throw;
            }
        }

        //公司KA下拉
        [HttpGet]
        public ResultModel<List<KaModel>> Down_KaModel()
        {
            try
            {
                var data = _companyAdminService.Down_KaModel();
                return MyOk(data);
            }

            catch (Exception)
            {

                throw;
            }
        }


        //显示公司管理
        [HttpGet]
        public IActionResult Show_CompanyAdminModel(int pageindex, int pagesize, int? com_ind_id, int? com_state, int? com_ka_id, int? com_mp4, int? com_ad, string com_name = "")
        {
            int totalcount = 0;
            var list = _companyAdminService.Show_CompanyAdminModel(out totalcount, pageindex, pagesize, com_ind_id, com_state, com_ka_id, com_mp4, com_ad, com_name);
            return Ok(new { list, totalcount });
              


        }

        //删除公司
        [HttpDelete]
        public ResultModel<int> Delete_CompanyAdminModel(int com_id)
        {
            try
            {
                var data = _companyAdminService.Delete_CompanyAdminModel(com_id);
                return MyOk(data);
            }

            catch (Exception)
            {

                throw;
            }
        }


        //详情
        [HttpGet]
        public ResultModel<CompanyAdminModel> Eait_Delete_CompanyAdminModel(int com_id)
        {
            try
            {
                var data = _companyAdminService.Eait_Delete_CompanyAdminModel(com_id);
                return MyOk(data);
            }

            catch (Exception)
            {

                throw;
            }
        }


        //修改
        [HttpPut]
        public ResultModel<int> Update_CompanyAdminModel(CompanyAdminModel companyAdminModel)
        {
            try
            {
                var data = _companyAdminService.Update_CompanyAdminModel(companyAdminModel);
                return MyOk(data);
            }

            catch (Exception)
            {

                throw;
            }
        }

        //添加
        [HttpPost]
        public ResultModel<int> Add_CompanyAdminModel(CompanyAdminModel companyAdminModel)
        {

            try
            {
                var data = _companyAdminService.Add_CompanyAdminModel(companyAdminModel);
                return MyOk(data);
            }

            catch (Exception)
            {

                throw;
            }
        }
    }
}
